<#include "/common/head.html"/>
<table id="dg"></table>
<div id="tb" style="padding: 2px 5px;">
	
	<div style="text-align: left; margin: 6px;">
		<a href="#" class="easyui-linkbutton addBtn" iconCls="glyphicon-plus"
			plain="true" onclick="add()">增加</a> <a href="#"
			class="easyui-linkbutton updateBtn" iconCls="glyphicon-pencil"
			plain="true" onclick="update()">编辑</a> <a href="#"
			class="easyui-linkbutton delBtn" iconCls="glyphicon-remove"
			plain="true" onclick="del()">删除</a> 
			<!-- <a href="javascript:void(0)"
			class="easyui-linkbutton detailBtn" iconCls="glyphicon-map-marker"
			plain="true" onclick="detail()">详情</a>
		<div id="searchBtnWrap" style="float: right; padding-right: 40px;">
			<a href="#" class="easyui-linkbutton color1"
				iconCls="glyphicon-search" onclick="zcurdSearch(this)">搜索</a> <a
				href="#" class="easyui-linkbutton" iconCls="glyphicon-repeat">重置</a>
		</div> -->
	</div>
</div>


<script type="text/javascript">
	var datagrid = $("#dg");

	var dgOptions = {
		rownumbers : true,
		fit : true,
		border : false,
		rownumbers : true,
		url : '${ctx}/equipment/listData',
		method : 'post',
		toolbar : '#tb',
		pageSize : 10,
		pagination : true,
		height :420,
		multiSort : true,
		queryParams : getInitParam(),
		columns : [ [
				{
					field : 'id',
					checkbox : true
				},
				{
					field : 'e_code',
					title : '编号',
					width : 120,
					sortable : true
				},
				{
					field : 'e_name',
					title : '名称',
					width : 120
				},
				{
					field : 'e_model',
					title : '规格',
					width : 120
				},
				{
					field : 'e_num',
					title : '需求数量',
					width : 150,
					sortable : true
				},{
					field : 'r_num',
					title : '实际数量',
					width : 150,
					sortable : true
				},
				{
					field : 'e_remark',
					title : '备注',
					width : 150,
					sortable : true
				}] ]
	};
	$(function() {
		handleAuthDataRule();
		datagrid.datagrid(dgOptions);
	});

	function zcurdSearch() {
		var param = zcurdGetParam();
		datagrid.datagrid("load", {
			queryParams : param
		})
	}

	function zcurdGetParam() {
		var param = {"queryParams[task_id]":${task_id},"queryParams[station_id]":"${station_id!}"};
		$("#tb :input[name]").each(function(i, item) {
			if ($(item).val()) {
				param[$(item).attr("name")] = $(item).val();
			}
		});
		return param;
	}

	function getInitParam() {
		var param = {"queryParams[task_id]":${task_id},"queryParams[station_id]":"${station_id!}"};
		$("#tb :input[name]").each(
				function(i, item) {
					if ($(item).val()) {
						param["queryParams[" + $(item).attr("name") + "]"] = $(
								item).val();
					}
				});
		return param;
	}
	//添加用户
	var initPara = zcurdGetParam();
	
	function add() {
		top.window.subPage.loadCurrDatagrid = function() {
			showMsg("增加成功！");
			datagrid.datagrid("load");
		}
		top.openWindow("机具管理-增加", "${ctx}/equipment/addPage?" + $.param(initPara),
				{
					size : '600x400'
				});
	}
	//更新用户信息
	function update() {
		var rowsSel = datagrid.datagrid("getSelections");

		if (rowsSel.length != 1) {
			showWarnMsg("请选择一条数据！");
			return;
		}
		var id = rowsSel[0].id;
		top.window.subPage.loadCurrDatagrid = function() {
			showMsg("更新成功！");
			datagrid.datagrid("load");
		}
		top.openWindow("机具管理-编辑", "${ctx}/equipment/updatePage?id=" + id, {
			size : '600x400'
		});
	}
	//删除用户
	function del() {
		var ids = [];
		$.each(datagrid.datagrid("getSelections"), function(i, item) {
			ids.push(item.id);
		});
		if (ids.length < 1) {
			showWarnMsg("请选择需要删除的数据！");
			return;
		}
		confirmMsg("确认删除？", function() {
			$.post("${ctx}/equipment/delete", {
				id : ids
			}, function(data) {
				showMsg("删除成功！");
				datagrid.datagrid("load");
			});
		});
	}	
</script>
<#include "/common/dialogWindow.html"/> <#include "/common/foot.html"/>
